<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="target-densitydpi=device-dpi, width=640px, user-scalable=no">
    <meta name="apple-themes-web-app-capable" content="yes">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <meta name="format-detection" content="telephone=no">
    <title>培优广场</title>
    <link rel="stylesheet" href="/static/index/css/main.css" type="text/css" media="all">
    <script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <style type="text/css">
        .search-title {
            position: absolute;
            left: 180px;
        }

        .topPosition {
            display: block;
            float: right;
            background-color: coral;
            color: white;
            font-size: 20px;
            border-radius: 5px;
            width: 50px;
            text-align: center;
        }
        .btnCate{
            margin-right: 15px;
            background-color: #1F9532;
            color: white;
            border-radius: 9px;
            position: absolute;
            top: 26px;
            left: 100px;
            width: 119px;
            text-align: center;
        }
        .btnDis{
            margin-right: 15px;
            background-color: #1E9FFF;
            color: white;
            border-radius: 9px;
            position: absolute;
            top: 26px;
            right: 100px;
            padding-left: 10px;
            padding-right: 10px;
            text-align: center;
            padding-top: 3px;
            padding-bottom: 3px;
            margin-top: -7px;
        }
        .btnHot{
            margin-right: 15px;
            background-color: #FF5722;
            color: white;
            border-radius: 9px;
            position: absolute;
            top: 26px;
            right: 10px;
            padding-left: 10px;
            padding-right: 10px;
            text-align: center;
            padding-top: 3px;
            padding-bottom: 3px;
            margin-top: -7px;
        }
    </style>
</head>
<body style="background: #fff;">
<!--页面加载 开始-->
<div id="preloader">
    <div id="status">
        <p class="center-text"><span>拼命加载中···</span></p>
    </div>
</div>
<!--页面加载 结束-->

<div id="content_div2">
    <div class="header">
        <a href="javascript:history.go(-1);" class="fanhui"></a>
    </div>
    <div><a href="{:url('index/Institution/institutionSearch')}" class="search search-title" style="width: 52%;">搜索</a></div>
    <span class="btnDis" id="distance">距离</span>
    <span class="btnHot" id="hot">热度</span>
    <div class="p640"></div>
    <style type="text/css">
        .bianmin li:last-child {
            border-bottom: 1px solid #ccc;
        }
    </style>
    <div class="bianmin">
        <ul id="dataList">
<!--            <li>-->
<!--                <div class="img">-->
<!--                    <a href="%s"  ><img src="%s"></a>-->
<!--                </div>-->
<!--                <a href="%s"  >-->
<!--                    <div class="text">-->
<!--                        <p>%s %s</p>-->
<!--                        <p class="ptime">%s <span>距离%sKM</span></p>-->
<!--                        <p class="ptime">联系方式：%s<span>10次</span></p>-->
<!--                    </div>-->
<!--                </a>-->
<!--            </li>-->
        </ul>
    </div>
    <div style="text-align: center;margin-top: 15px;" id="showMoreDiv">
        <button style=" width: 200px;height: 45px;    border-radius: 12px;" value="1" id="showMoreBtn">点击加载更多</button>
    </div>
    <div style="text-align: center;margin-top: 15px;display: none" id="noMoreDiv">
        <button style=" width: 200px;height: 45px;    border-radius: 12px;">没有更多信息</button>
    </div>
    <div style="text-align: center;margin-top: 15px;display: none" id="loaddingDiv">
        <button style=" width: 200px;height: 45px;    border-radius: 12px;">加载中...</button>
    </div>

</div>

<!--底部-->
<div class="foot_nav">
    <ul>
        <li>
            <a href="/">
                <img src="/static/index/images/nav1.png"/>
                <p>首页</p>
            </a>
        </li>
        <li class="active">
            <a href="{:url('index/Institution/institutionList')}">
                <img src="/static/index/images/nav2-active.png"/>
                <p>培优</p>
            </a>
        </li>

        <li>
            <a href="{:url('index/Article/goodClassList')}">
                <img src="/static/index/images/nav3.png" style="width: 45px;height: 42px;margin-top: -6px;"/>
                <p>好课</p>
            </a>
        </li>
        <li>
            <a href="{:url('index/Article/goodArticleList')}">
                <img src="/static/index/images/nav4.png"/>
                <p>好文</p>
            </a>
        </li>
        <li>
            <a href="http://wechat.wx.0579bb.com/app/index.php?i=7&c=entry&do=forum&m=meepo_bbs">
                <img src="/static/index/images/nav5.png"/>
                <p>BBS</p>
            </a>
        </li>
    </ul>
</div>

<!--底部结束-->

<!--储存经纬度-->
<input type="hidden" id="longitude" value="-1">
<input type="hidden" id="latitude" value="-1">


<script type="text/javascript" src="/static/index/js/zepto.js"></script>
<script type="text/javascript" src="/static/index/js/carousel-image.js"></script>
<script>
    $('.carousel-image').CarouselImage({
        num: $('.carousel-image .carousel-num'),
        repeat: true
    });
</script>
<script type="text/javascript" src="/static/index/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/index/js/common.js"></script>
<script type="text/javascript" src="/static/index/js/iscroll.js"></script>
<script type="text/javascript" src="/static/index/js/navbarscroll.js"></script>
<script type="text/javascript">
    $(function () {
        $('.wrapper').navbarscroll();
        //配置微信参数获取坐标
        wx.config({$SDKParams});
        wx.ready(function () {
            // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
            wx.getLocation({
                type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
                success: function (res) {
                    var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                    var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                    $("#latitude").val(latitude);
                    $("#longitude").val(longitude);
                    getData(1, latitude, longitude);
                },
                fail: function (res) {
                }
            });

            $("#showMoreBtn").click(function () {
                var value = $("#showMoreBtn").val();
                value = parseInt(value);
                value += 1;
                $("#showMoreBtn").val(value);
                showLoading();
                getData(value);
            });

        });
    });

    // getData(1);
    function getData(page, latitude = null, longitude = null) {
        if (latitude == null && longitude == null) {
            latitude = $("#latitude").val();
            longitude = $("#longitude").val();
        }

        $.ajax({
            url: "{:url('index/Institution/institutionList')}",
            type: "post",
            data: {
                page: page,
                latitude: latitude,
                longitude: longitude,
                ins_name: "{$ins_name}",
                ins_lessons: "{$ins_lessons}",
                orderType:"{$orderType}"

            },
            dataType: "json",
            success: function (res) {
                var html = res.data.html;
                var hasMore = res.data.hasMore;
                $("#dataList").append(html);
                if (hasMore == 1) {
                    showMore();
                } else {
                    showNoMore();
                }
            }
        })
    }

    function showLoading() {
        $("#showMoreDiv").css("display", "none");
        $("#noMoreDiv").css("display", "none");
        $("#loaddingDiv").css("display", "block");
    }


    function showNoMore() {
        $("#showMoreDiv").css("display", "none");
        $("#noMoreDiv").css("display", "block");
        $("#loaddingDiv").css("display", "none");
    }

    function showMore() {
        $("#showMoreDiv").css("display", "block");
        $("#noMoreDiv").css("display", "none");
        $("#loaddingDiv").css("display", "none");
    }

</script>
<script type="text/javascript">
    $("#chooseCate").click(function () {
        window.location.href = "{:url('index/index/chooseCategory')}";
    });
    $("#distance").click(function(){
        window.location.href="{:url('index/Institution/institutionList')}?ins_name={$ins_name}&ins_lessons={$ins_lessons}&order=distance";
    });
    $("#hot").click(function(){
        window.location.href="{:url('index/Institution/institutionList')}?ins_name={$ins_name}&ins_lessons={$ins_lessons}&order=hot";
    });
</script>
</body>
</html>
